<?php echo $this->load->view('meta'); ?>
<script type="text/javascript" language="JavaScript">
	$(document).ready(function() {
		$('.group .group_body').hide();
		$('.group .group_meta span a').addClass('show');
		$('.group').find('span a').click(function() {
			$(this).parent('span').parent('div').next().slideToggle();
			$(this).toggleClass('show').toggleClass('hide');
			return false;
		});
		$('#expand').click(function() {
			$('.group').find('.group_body').slideDown();
			$('.group').find('span a').removeClass('show').addClass('hide');
			return false;
		});
		$('#collapse').click(function() {
			$('.group').find('.group_body').slideUp();
			$('.group').find('span a').removeClass('hide').addClass('show');
			return false;
		});
	});
</script>
<title>xa-ncsu | groups - my groups</title>
<?php echo $this->load->view('header'); ?>
<div id="group_header">
	<p><a href="#" id="expand">expand all</a> / <a href="#" id="collapse">collapse all</a></p>
	<h1>My groups</h1>
</div>
<?php if ($groups != FALSE): ?>
<?php foreach ($groups->result() as $group): ?>
<div class="group">
	<div class="group_meta">
		<span><a href="#"></a></span>
		<h2><?=$group->description?></h2>
		<p class="right"><?php if ($group->rank == '1') { echo anchor('mail/composeMail/group/'.$group->groupid,'send message'); } ?></p>
		<p>Members: <?=$group->group_members->num_rows()?></p>
	</div>
	<div class="group_body">
		<h3>Members</h3>
		<ul>
		<?php foreach($group->group_members->result() as $row): ?>
			<li><?=$row->user->display?><?php if ($row->rank == '1') echo '<img src="'.base_url().'img/icons/medal_gold_1.png" alt="Leader" />'; ?></li>
		<?php endforeach; ?>
		</ul>
	</div>
	<ul class="group_footer clearfix">
	</ul>
</div>
<?php endforeach; ?>
<?php else: ?>
<p>You are not a member of any groups.</p>
<?php endif; ?>
<?php echo $this->load->view('footer'); ?>